﻿#include <iostream>
using namespace std;
const int N = 1e5 + 10;
//将顺序表的创建以及增删查改封装在⼀个类中
class SqList
{
	int a[N];
	int n;
public:
	//构造函数，初始化
    SqList()
    {
        n = 0;
    }
    //尾插
    void push_back(int x)
    {
        a[++n] = x;
    }
    //尾删
    void pop_back()
    {
        n--;
    }
    //打印
    void print()
    {
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
    }
};
int main()
{
    SqList s1, s2; //创建了两个顺序表

    for (int i = 1; i <= 5; i++)
    {
    //直接调⽤s1和s2里面的push_back
        s1.push_back(i);
        s2.push_back(i * 2);
    }
    s1.print();
    s2.print();
    for (int i = 1; i <= 2; i++)
    {
        s1.pop_back();
        s2.pop_back();
    }
    s1.print();
    s2.print();
    return 0;
}
//#include<iostream>
//using namespace std;
//const int N = 50;
//class SqList {
//	int a[N];
//	int n;
//
//public:
//	SqList()
//	{
//		n = 0;
//	}
//	//尾插
//	void push_back(int x)
//	{
//		a[++n] = x;
//
//	}
//	//打印
//	void print()
//	{
//		for (int i = 1; i <= n; i++)
//		{
//			cout << a[i] << " ";
//		}
//		cout << endl;
//	}
//};
//int main()
//{
//	SqList s1, s2;
//	for (int i = 1; i <= 5; i++)
//	{
//		s1.push_back(i);
//		s2.push_back(i * 2);
//	}
//	s1.print();
//	s2.print();
//	return 0;
//}
////#include <iostream>
////using namespace std;
////const int N = 1e6 + 10; // 根据实际情况⽽定
////
//////创建顺序表
//// int a[N]; // ⽤⾜够⼤的数组来模拟顺序表
//// int n; //标记顺序表⾥⾯有多少个元素
////
//////需要多个顺序表，才能解决问题
////int a1[N], n1;
////int a2[N], n2;
////int a3[N], n3;
////// 打印顺序表
////void print()
////{
////	for (int i = 1; i <= n; i++)
////	{
////		cout << a[i] << " ";
////	}
////	cout << endl << endl;
////}
//////尾插
////void push_back(int a[], int& n, int x)
////{
////	a[++n] = x;
////}
////void test()
////{
////	push_back(a1, n1, 1);
////	push_back(a3, n3, 2);
////}
//////头插
////void push_front(int x)
////{
////	// 1.先把[1, n]的元素统⼀向后移动⼀位
////	for (int i = n; i >= 1; i--)
////	{
////		a[i + 1] = a[i];
////	}
////	// 2.把x放在表头
////	a[1] = x;
////	n++; //元素个数+ 1
////}
//////在任意位置插⼊
////void insert(int p, int x)
////{
////	// 1.先把[p, n]的元素统⼀向后移动⼀位
////	for (int i = n; i >= p; i--)
////	{
////		a[i + 1] = a[i];
////	}
////	a[p] = x;
////	n++;
////}
//////尾删
////void pop_back()
////{
////	n--;
////}
//////头删
////void pop_front()
////{
////	// 1.先把[2, n]区间内的所有元素，统⼀左移⼀位
////	for (int i = 2; i <= n; i++)
////	{
////		a[i - 1] = a[i];
////	}
////	n--;
////}
//////任意位置删除
////void erase(int p)
////{
////	//把[p + 1, n]的元素，统⼀左移⼀位
////	for (int i = p + 1; i <= n; i++)
////	{
////		a[i - 1] = a[i];
////	}
////	n--;
////}
//////按值查找
////int find(int x)
////{
////	for (int i = 1; i <= n; i++)
////	{
////		if (a[i] == x) return i;
////	}
////	return 0;
////}
//////按位查找
////int at(int p)
////{
////	return a[p];
////}
//////按位修改
////int change(int p, int x)
////{
////	a[p] = x;
////}
//////清空操作
////void clear()
////{
////	n = 0;
////}
////int main()
////{
////	//测试尾插
////	push_back(2);
////	print();
////	push_back(5);
////	print();
////	push_back(1);
////	print();
////	push_back(3);
////	print();
////	//测试头插
////	push_front(10);
////	print();
////	//测试任意位置插⼊
////	insert(3, 0);
////	print();
////	//测试尾删
////	// cout << "尾删：" << endl; 
////	// pop_back();
////	// print();
////	// pop_back();
////	// print();
////	// pop_front();
////	// pop_front();
////	// print();
////	// 测试任意位置删除
////	// cout << "任意位置删除：" << endl; 
////	// erase(3);
////	// print();
////	// erase(2);
////	// print();
////	// erase(4);
////	// print();
////	for (int i = 1; i <= 10; i++)
////	{
////		cout << "查找" << i << ": ";
////		cout << find(i) << endl;
////	}
////	return 0;
////}